package yelmor.comm100.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.web.csrf.CsrfToken;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import yelmor.comm100.domain.CoUser;
import yelmor.comm100.repository.CoUserRepository;
import yelmor.comm100.repository.CoUserRoleRepository;
import yelmor.comm100.util.SecurityUtil;

/**
 * Created by yel on 2016/5/7.
 */
@Controller
public class ImageConfigController {

  @Autowired
  CoUserRepository coUserRepository;

  @RequestMapping("/user/imgConfig")
  public String imgConfig(Model model) {
    String curUserName = SecurityUtil.getCurrentUserName();
    if(curUserName.equals("anonymousUser")) {
      model.addAttribute("notLogin", true);
    } else {
      model.addAttribute("userName", curUserName);
      CoUser coUser = coUserRepository.findOne(curUserName);
      model.addAttribute("coUser", coUser);
      return "imgCustom";
    }
    return "redirect:/";
  }
}
